<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>增加学位</title>
    <script src="../../js/jquery.js"></script>
    <script src="../../js/serializeObject.js"></script>
    <script type="application/javascript">
        //提交函数
        function submit_onClick() {
            //调用serializeObject函数，将表单数据序列化，形成JSON对象
            var formData = $('#degreeForm').serializeObject();
            //JSON对象文本化
            var degree_json = JSON.stringify(formData);
            alert(degree_json);
            //Ajax请求
            $.ajax({
                url: "/addDegree.ctl",
                type: "post",
                //请求参数
                data: degree_json,
                //请求参数字符集
                contentType: "application/json;charset=utf-8",
                //响应数据的格式
                dataType: "json",
                success: function (msg) {
                    // 响应数据为JSON对象，而非字串，故无须转换
                    alert("状态:" + msg.MSG);
                    //重定向
                    window.location.replace("/html/basic/degree.html");
                },
                error: function (msg) {
                    alert("添加失败");
                }
            });
        }
    </script>
</head>
<body>
<form id="degreeForm">
    <label for = "no">NO</label>
    <input name="no" id="no" value="00"/>
    <label for = "description">DEGREE</label>
    <input name="description" id = "description" value="博士"/>
    <input type="button" name="submit"
           onclick="submit_onClick();" value="提交"/>
</form>
</body>
</html>
